package com.zzyl.nursing.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzyl.common.utils.SecurityUtils;
import com.zzyl.nursing.domain.AlertData;
import com.zzyl.nursing.dto.AlertDataHandleDto;
import com.zzyl.nursing.dto.AlertDataPageQueryDto;
import com.zzyl.nursing.mapper.AlertDataMapper;
import com.zzyl.nursing.service.IAlertDataService;
import com.zzyl.nursing.vo.AlertDataVo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 报警数据Service业务层处理
 *
 * @author Zhy
 * @date 2025-03-11
 */
@Service
@RequiredArgsConstructor
public class AlertDataServiceImpl extends ServiceImpl<AlertDataMapper, AlertData> implements IAlertDataService {


	@Autowired
	private AlertDataMapper alertDataMapper;
	@Override
	public List<AlertDataVo> getAlertData(AlertDataPageQueryDto alertDataPageQueryDto) {
		return alertDataMapper.getAlertData(alertDataPageQueryDto);
	}



	@Override
	public void processHandleAlertData(AlertDataHandleDto alertDataHandleDto) {

			AlertData alertData = BeanUtil.copyProperties(alertDataHandleDto, AlertData.class);
			alertData.setStatus(1);
			alertData.setProcessorName(SecurityUtils.getUsername());
			alertData.setProcessorId(SecurityUtils.getUserId());

			alertDataMapper.updateById(alertData);

	}
}
